package com.gem.eolane.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gem.eolane.entity.PcbOffer;
import com.gem.eolane.mapper.SurfaceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SurfaceService extends ServiceImpl<SurfaceMapper,PcbOffer> {
    //默认第一页开始
    public static Integer CURRENT_PAGE = 1;
    //每页显示数据数量
    public static Integer PAGE_SIZE = 4;

    @Autowired
    private SurfaceMapper surfaceMapper;

    //查询当前用户的历史订单
    public IPage<PcbOffer> findUid(Integer id, Integer page, Integer size){
        if (page == null) {
            page = CURRENT_PAGE;
        }
        if (size == null) {
            size = PAGE_SIZE;
        }
        return surfaceMapper.selectPage(new Page<>(page,size),
                 new QueryWrapper<PcbOffer>().eq("user_id",id));
     }

     //查询当前用户历史订单数量
//    public Integer fcount(Integer id){
//        return surfaceMapper.fcount(id);
//    }

    //查询当前用户的历史订单详情
    public List<PcbOffer> findpcblist(String id){
         return surfaceMapper.finpcblist(id);
   }

   //根据用户输入的邮箱判断用户是否存在
    public String finuse(String email){
        return surfaceMapper.finuse(email);
    }

    //更新密码
    public void upword(String mail,String password){
        surfaceMapper.upword(mail,password);
    }


}
